package reflect;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.TypeVariable;

/**
 * @author DBX
 * @effect
 * @date 2021/09/13/22:42
 */
public class ReflectTest06 {
    public static void main(String[] args) throws Exception{
        Class c = Class.forName("java.lang.String");
        StringBuilder sb = new StringBuilder();
        sb.append(Modifier.toString(c.getModifiers()));
        sb.append(" class ");
        sb.append(c.getSimpleName()+"{\n");
        Field[] fields = c.getDeclaredFields();
        for (Field field : fields) {
            sb.append("\t");
            sb.append(Modifier.toString(field.getModifiers()));
            sb.append(" ");
            sb.append(field.getType().getSimpleName());
            sb.append(" ");
            sb.append(field.getName());
            sb.append(";\n");
        }
        Method[] methods = c.getMethods();
        for (Method method : methods) {
            sb.append("\t");
            sb.append(Modifier.toString(method.getModifiers()));
            sb.append(" ");
            sb.append(method.getReturnType().getSimpleName());
            sb.append(" ");
            sb.append(method.getName());
            sb.append("(");
            Class[] paraType = method.getParameterTypes();

            for (Class aClass : paraType) {
                sb.append(aClass.getSimpleName());
                sb.append(",");
            }
            if (paraType.length>0){
                sb.deleteCharAt(sb.length()-1);
            }

            sb.append("){}");
            sb.append("\n");
        }
        sb.append("}");
        System.out.println(sb);

    }
}
